/* $Id: pluggie.jquery.js 29 2009-10-22 19:58:19Z geraldb $

jQuery Plugin Helper

*/

(function($) {
$.pluggie = function(name, plug) {
	$.fn[name] = function(parameters) {
		var plug_name = 'pluggies:' + name;
		var my_plug = this.data(plug_name);
		var orig_object = this;

		if ( my_plug && typeof my_plug != 'undefined' ) {
			var is_function = ( typeof parameters === 'string' && parameters.substr(0, 1) != '_' ) ? true : false;
			if ( is_function ) {
				var args = Array.prototype.slice.call( arguments, 1 );
				return my_plug[parameters].apply(my_plug, args);
			}
			return;
		}

		return this.each(function() {
			var my_plug = new plug();
			var $this = $(this);
			$this.data(plug_name, my_plug);
			my_plug._init($this, parameters, orig_object);
		});
	};
};
})(jQuery);